var num=location.search;
num=num.split('?')[1];
var name;
$('.num').text(num);
$('.title').append(num);
if (islogin()) {
    $.post({
        url:'../requests/admin/select_teacher_edit.php',
        data:{'num':num},
        success:function (data) {
            if (data == 'no_login') {
                // window.location.href='login.html';
                console.log('data');
            }
            else {
                $("input[name='name']").val(data);
                name=data;
            }
        }
    });

    $('#btn_edit').click(function () {
        var new_name=$("input[name='name']").val();
        if (name == new_name) {
            $$.alert('姓名未修改');
        }
        else {
            $.post({
                url: '../requests/admin/edit_teacher_name.php',
                data: {'num': num, 'name': new_name},
                success: function (data) {
                    if (data = -'1') {
                        $$.alert('修改成功', function () {
                            window.location.href = 'teachers.html';
                        });
                    }
                    else if (data == 'no_exist') {
                        $$.alert('账号不存在', function () {
                            location.reload(true);
                        });
                    }
                    else {
                        $$.alert(data, function () {
                            window.location.href = 'login.html';
                        });
                    }
                }
            });
        }
    });

}
